const path=require('path');
const HtmlWebpackPlugin=require('html-webpack-plugin');
const CleanWebpackPlugin=require('clean-webpack-plugin');
const webpack=require("webpack");
const extractTextWebpackPlugin=require('extract-text-webpack-plugin');
const purifycsswebpack=require('purifycss-webpack');
const glob=require('glob');
const ruses=require('./webpack.ruls.js')

module.exports={
	entry:{//入口
		a:'./src/index.js'
	},
	output:{//出口
		path:path.resolve(__dirname,'dist'),
		filename:'test.js'
	},
	module:ruses,
	devServer:{
		//设置服务区访问的基本目录
		contentBase:path.resolve(__dirname,'dist'),
		//服务器ip地址，localhost
		host:'localhost',
		//设置端口
		port:3000,
		//热应用
		hot:true,
		//控制浏览器是否打开
		open:true
	},
	plugins:[//压缩配置
	new webpack.HotModuleReplacementPlugin(),
	new CleanWebpackPlugin(['dist']),//自动清除文件
	new HtmlWebpackPlugin({//压缩配置
		chunks:['a'],
		filename:'index.html',
		template:'./src/index.html',
		hash:true,
	}),
	new extractTextWebpackPlugin('css/1.css'),
	new purifycsswebpack({
		paths:glob.sync(path.join(__dirname,'src/*.html'))
	})
	],
	
	// resolve:{
	// 	alias:{//修改vue被导入时候的包的路径
	// 		"vue$":'vue/dist/vue.js'
	// 	}
	// }
}